<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>图书管理</title>
<link type="text/css" rel="stylesheet" href="/static/css/style.css" >
<script src="/static/script/jquery-1.7.2.js"></script>
<script>
	$(function() {
		//给删除图书的超链接绑定事件
		$(".deleteBook").click(function() {
			//获取书名
			var title = $(this).attr("id");
			// var flag = confirm("确定要删除["+title+"] 这本图书吗?");
			// if (!flag){
			// 	//取消默认行为
			// 	return false;
			// }
			return confirm("确定要删除["+title+"] 这本图书吗?");
		});
	});
</script>
</head>
<body>
	
	<div id="header">
			<img class="logo_img" alt="" src="/static/img/logo.gif" >
			<span class="wel_word">图书管理系统</span>
			<div>
				<a href="/getPageBooks">图书管理</a>
				<a href="/main">返回商城</a>
			</div>
	</div>
	
	<div id="main">
		<table>
			<tr>
				<td>名称</td>
				<td>价格</td>
				<td>作者</td>
				<td>销量</td>
				<td>库存</td>
				<td colspan="2">操作</td>
			</tr>
			{{range .Books}}
			<tr>
				<td>{{.Title}}</td>
				<td>{{.Price}}</td>
				<td>{{.Author}}</td>
				<td>{{.Sales}}</td>
				<td>{{.Stock}}</td>
				<td><a href="/toUpdateBookPage?bookId={{.Id}}">修改</a></td>
				<td><a id="{{.Title}}" class="deleteBook" href="/deleteBook?bookId={{.Id}}">删除</a></td>
			</tr>
			{{end}}
			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td><a href="/toUpdateBookPage">添加图书</a></td>
			</tr>
		</table>
		<div id="page_nav">
		{{if .IsHasPrev}}
			<a href="/getPageBooks">首页</a>
			<a href="/getPageBooks?pageNo={{.GetPrevPageNo}}">上一页</a>
		{{end}}
			当前是第{{.PageNo}}页. 共{{.TotalPageNo}}页，共{{.TotalRecord}}条记录
		{{if .IsHasNext}}
			<a href="/getPageBooks?pageNo={{.GetNextPageNo}}">下一页</a>
			<a href="/getPageBooks?pageNo={{.TotalPageNo}}">末页</a>
		{{end}}
			 到第<input value="{{.PageNo}}" name="pn" id="pn_input"/>页
			<input type="button" value="确定" id="sub" >
			<script>
				//给确定按钮绑定单击事件
				$("#sub").click(function () {
					//获取输入的页码
					var pageNo = $("#pn_input").val()
					location = "/getPageBooks?pageNo="+pageNo
				});
			</script>
		</div>
	</div>
	
	<div id="bottom">
		<span>
			五行哥书城.Copyright &copy;2015
		</span>
	</div>
</body>
</html>